/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package mx.edu.itesm.daai.controladores;

import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.xml.sax.SAXException;
import java.util.Vector;
import mx.edu.itesm.daai.xao.XAO;
/**
 *
 * @author Karina
 */
public class Noticias extends HttpServlet {
    public Vector contenido;
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        System.out.println("Procesando controlador noticioso");
        String noticiasccm = request.getParameter("noticiasccm");
        // Primero, prepara el ambiente para generar el contenido
        response.setContentType("text/xml; charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            // ahora, ve a recoger las noticias desde una fuente XML editada desde
            // un sitio externo, en forma editorial...
            XAO xao = new XAO();
            
            //String noticias = xao.XAODBQuery();
            contenido= new Vector();
            char m='"';

            String noticias = xao.XAODBQuery(getServletConfig().getServletContext().getInitParameter("acuario"),getServletConfig().getServletContext().getInitParameter("driver"));
            out.println(noticias);
            //out.println("<p></p>");
            //out.println("<div>"+xao.respuestat[i]+"</div>");
            //out.println("Fecha:<b>"+xao.respuestaf[i]+"</b>");
            //out.println("Fecha:<b>"+fecha+"</b>");

            out.close();
        } catch (Exception e) {
        } finally {
        } // fin try-catch

    }
        // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @throws javax.servlet.ServletException
     * @throws java.io.IOException
     * @param response servlet response
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @throws javax.servlet.ServletException
     * @throws java.io.IOException
     * @param response servlet response
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Returns a short description of the servlet.
     * @return
     */
    public String getServletInfo() {
        return "Short description";
    }
    // </editor-fold>

}